package com.sicheng.lc.周赛.分类.模拟;

/**
 * @author zsc
 * @version 1.0
 * @date 2022/6/26 10:33
 */
public class 判断矩阵是否是一个X矩阵 {
    //https://leetcode.cn/contest/weekly-contest-299/problems/check-if-matrix-is-x-matrix/
    public boolean checkXMatrix(int[][] grid) {
        for (int i = 0; i < grid.length; i++) {
            for (int j = 0; j < grid.length; j++) {
                if (i == j || i + j == grid.length - 1) {
                    if (grid[i][j] == 0)
                        return false;
                } else if (grid[i][j] != 0)
                    return false;
            }
        }
        return true;
    }
}
